package com.yjh;

import java.sql.*;

//这个类是将mysql的数据批量删除
public class DelectData {
    public static void main(String[] args) {
        int number = 10000;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn = DriverManager.getConnection("jdbc:mysql://hadoop103:3306/db01", "root", "123456");
            String sql  =" delete from t2 where id = ?";
            for (int i = 0; i < number; i++) {
                PreparedStatement statement = conn.prepareStatement(sql);
                statement.setInt(1,i);
                statement.executeUpdate();
                statement.close();
            }


            conn.close();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }

}
